package com.kongxx.struts2study.json;

import com.kongxx.struts2study.user.model.User;
import com.opensymphony.xwork2.Action;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

public class JSONExample2 {

	private List<User> userList = new ArrayList<User>();

	private Map<String, User> userMap = new LinkedHashMap<String, User>();

	public String getMyUserList() {
		for (int i = 0; i < 3; i++) {
			User user = new User("id_" + i, "username_" + i, "password_" + i, "desc_" + i);
			userList.add(user);
		}
		return Action.SUCCESS;
	}

	public String getMyUserMap() {
		for (int i = 0; i < 3; i++) {
			User user = new User("id_" + i, "username_" + i, "password_" + i, "desc_" + i);
			userMap.put(user.getId(), user);
		}
		return Action.SUCCESS;
	}

	public List<User> getUserList() {
		return userList;
	}

	public void setUserList(List<User> userList) {
		this.userList = userList;
	}

	public Map<String, User> getUserMap() {
		return userMap;
	}

	public void setUserMap(Map<String, User> userMap) {
		this.userMap = userMap;
	}

}
